<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
	<title>购物车</title>
</head>
<body>
	<!-- header.jsp -->
	<jsp:include page="../header.jsp"></jsp:include>
	<!-- /header.jsp -->

	<!-- SECTION -->
	<div class="section">
		<!-- container -->
		<div class="container">
			<!-- row -->
			<div class="row">
				<div class="col-md-12">

					<div class="table-responsive">
						<c:if test="${empty cart || empty cart.cartItems}">
							<h3>你还没有添加商品到购物车哦，请<a href="${pageContext.request.contextPath}/">接着逛逛</a></h3>
						</c:if>
						<c:if test="${not empty cart.cartItems }">
							<table class="table table-bordered" style="text-align: center;">
								<caption>购物车详情</caption>
								<tbody>
									<tr style="font-weight: bold;">
										<td>商品图片</td>
										<td>商品名称</td>
										<td>商品单价</td>
										<td>商品数量</td>
										<td>小计</td>
										<td>操作</td>
									</tr>
									<c:forEach items="${cart.cartItems }" var="item">
										<tr>
											<td width="60" width="40%" style="vertical-align: middle;">
												<img src="${pageContext.request.contextPath}/${item.product.pimage}" width="70" height="60">
											</td>
											<td width="30%" style="vertical-align: middle;">
												<a target="_blank" href="${pageContext.request.contextPath}/product?method=productDetails&pid=${item.product.pid}">${item.product.pname}</a>
											</td>
											<td width="20%" style="vertical-align: middle;">
												￥${item.product.shop_price}
											</td>
											<td width="10%" style="vertical-align: middle;">
												${item.count}
											</td>
											<td width="15%" style="vertical-align: middle;">
												<span class="subtotal">${item.subTotal}</span>
											</td>
											<td style="vertical-align: middle;">
												<a href="javascript:void(0);" onclick="isSureRemoveProduct('${item.product.pid}')" class="delete" title="移除">
													<i class="fa fa-trash-o" style="color: red;"></i>
												</a>
											</td>
										</tr>
									</c:forEach>
								</tbody>
							</table>
							<div style="text-align: right;">
								商品合计：<i class="fa fa-rmb" aria-hidden="true"></i>${cart.total}
								<br>
								<br>
								<button class="btn btn-danger" style="border-radius: 25px;background-color: #D10024;" onclick="removeAllFromCart()">清空购物车</button>
								<button class="btn btn-danger" style="border-radius: 25px;background-color: #D10024;" onclick="saveOrder()">&nbsp;&nbsp; 去结算 &nbsp;&nbsp;</button>

							</div>
						</c:if>
					</div>
				</div>
			</div>
			<!-- /row -->
		</div>
		<!-- /container -->
	</div>
	<!-- /SECTION -->

	<!-- footer.jsp -->
	<jsp:include page="../footer.jsp"></jsp:include>
	<!-- /footer.jsp -->

</body>
</html>
